import request from '@/config/axios'
import type { MemberType } from './types'

type MemberTypeOutlet = {
  hotel_id: string | undefined
  member_type_id: string
  outlets: string[]
}

export const getMemberTypesListApi = (params: any): Promise<IResponse> => {
  return request.get({ url: '/member-types', params })
}

export const createMemberTypesApi = (data: Partial<MemberType>): Promise<IResponse> => {
  return request.post({ url: '/member-types', data })
}

export const createMemberTypeOutletApi = (data: Partial<MemberTypeOutlet>): Promise<IResponse> => {
  return request.post({ url: '/member-types/outlets', data })
}

export const updateMemberTypesApi = (id: string, data: Partial<MemberType>): Promise<IResponse> => {
  return request.put({ url: `/member-types/id/${id}`, data })
}

export const getMemberTypesDetailApi = (id: string): Promise<IResponse<MemberType>> => {
  return request.get({ url: `/member-types/id/${id}` })
}

export const delMemberTypesListApi = (ids: string[] | number[]): Promise<IResponse> => {
  return request.delete({ url: `/member-types/id/${ids[0]}` })
}
